home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Engineering Notes / Views / Miscellaneous Views < prev    next >
Encoding:
Text File  |  1996-08-16  |  6.9 KB  |  159 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                     
  5. Miscellaneous Views
  6. ODF Release 1                                                                                                                                                             
  7.  
  8.  
  9. Table of Contents
  10. ----------------------
  11. • Static Text (FW_CStaticText)
  12.     • Creation by Program or by Resource
  13.     • API Reference
  14. • Group Box (FW_CGroupBox)
  15.     • Creation by Program or by Resource
  16.     • API Reference
  17. • Grow Box (FW_CGrowBox)
  18.     • Creation by Program or by Resource
  19.  
  20.  
  21. Static Text  (FW_CStaticText)
  22.  
  23. Creation by Program or by Resource
  24.  
  25. A static text view allows you to draw  non editable text.   It is basically a view wrapper for a FW_CTextBoxShape object.   You can specify its bounds, text, font and text box options.
  26.  
  27. When creating one by program you would use one of the 2 class constructors:
  28.  
  29.      FW_CStaticText(Environment* ev, 
  30.                                 FW_CSuperView* container, 
  31.                                    const FW_CRect& bounds, 
  32.                                    const FW_CString& text,
  33.                                    const FW_CFont& font = FW_kNormalFont,  
  34.                                    FW_TextBoxOptions options = FW_kTextBoxClipToBox,
  35.                                    const FW_CInk& ink = FW_kNormalTextInk);  
  36.  
  37.      FW_CStaticText(Environment* ev, 
  38.                                    FW_CSuperView* container, 
  39.                                    const FW_CTextBoxShape& textboxshape);
  40.  
  41. The first one is easier to use with its default values, you can write for example:
  42.  
  43.       FW_CStaticText* staticText1 = FW_NEW(FW_CStaticText, 
  44.                                   (ev, this, viewRect, FW_CString("Pick a password:")));
  45.  
  46. The second one requires to pass a reference to a text box shape.  It makes a copy of the shape to keep in its fTextBoxShape field.
  47.  
  48. By resource you can only define the text and font on top of the normal view attributes:
  49.  
  50.         FW_RStaticText
  51.         (
  52.                  0,                                                                                            // view id is not used
  53.                     { FW_FIX(20),FW_FIX(40),FW_FIX(140),FW_FIX(60)}, // bounds
  54.                     FW_kFixedBounds,                                                            // standard bindings
  55.                     FW_NORMAL_FONT, 
  56.                     "Pick a password:"            
  57.         ),
  58.  
  59. In order to change the default ink and text box options you must access the underlying text box shape  with GetTextBoxShape and call its methods.  
  60.  
  61. Notes:
  62.  
  63. • Being views  static text objects derive also from FW_MEventHandler, although they are disabled by default.  You can re-enable them with Enable()  if want them to receive events.
  64.  
  65. • Another way to draw static text in your frame is to use a background picture as it is done in Form.  This is not portable to other platforms but it can be convenient when there is a lot of text.
  66.  
  67.  
  68. API Reference
  69.  
  70. void                GetText(Environment* ev, FW_CString& text) const;
  71.     
  72. GetText returns the string stored in the underlying text box shape.  The size of text is adjusted dynamically.
  73.  
  74. void                SetText(Environment* ev, const FW_CString& text, 
  75.                                  FW_Boolean refresh = TRUE);
  76.  
  77. SetText replace the current string with text.  It redraws the view if refresh is true.  The text can be displayed on several lines if you created the static text object with the proper text box options, or if the string contains <cr> characters.
  78.  
  79. FW_CTextBoxShape*    GetTextBoxShape(Environment* ev);
  80.  
  81. GetTextBoxShape returns a pointer to the underlying text box shape.  This allows you to modify its attributes.  Call staticText->Invalidate(ev) afterward to force a redraw.
  82.  
  83.  
  84. Group Box  (FW_CGroupBox)
  85.  
  86. Creation by Program or by Resource
  87.  
  88. A group box view is a box with a label.  FW_CGroupBox derives from FW_CStaticText.  The static text is displayed as a label on the top border and the box is drawn using the view bounds rectangle.  The label position within the top border depends on the text box options choosen.  By default it is placed to the left (FW_kTextBoxJustifyLeft) you can also center it (FW_kTextBoxJustifyHCenter) or place it to the right (FW_kTextBoxJustifyRight).
  89.  
  90. FW_CGroupBox views are useful to group several other views visually.  For instance sets of radio buttons are usually displayed with inside a group box (this is separate from the FW_CRadioCluster object that manages the toggling of radio buttons).
  91.  
  92. When creating one by program you would use one of the 2 class constructors:
  93.  
  94.      FW_CGroupBox (Environment* ev, 
  95.                                FW_CSuperView* container, 
  96.                                   const FW_CRect& bounds, 
  97.                                   const FW_CString& text, 
  98.                                   const FW_CFont& font = FW_kNormalFont,  
  99.                                   FW_TextBoxOptions options = FW_kTextBoxClipToBox,
  100.                                   const FW_CInk& textInk = FW_kNormalTextInk,  
  101.                                   const FW_CInk& frameInk = FW_kNormalInk);
  102.  
  103.      FW_CGroupBox (Environment* ev, 
  104.                                   FW_CSuperView* container, 
  105.                                   const FW_CTextBoxShape& textbox,
  106.                                   const FW_CInk& frameInk = FW_kNormalInk);
  107.  
  108. The only addition to FW_CStaticText constructors is frameInk, the ink used to draw the box.
  109.  
  110. The resource type FW_RGroupBox is identical to FW_RStaticText.  
  111.  
  112. API Reference
  113.  
  114. There is no new API.  Use GetText, SetText or GetTextBoxShape to read or modify the text.  Use SetSize to change the size of the box.
  115.  
  116.  
  117. Grow Box  (FW_CGrowBox)
  118.  
  119. Creation by Program or by Resource
  120.  
  121. FW_CGrowBox implements the standard Macintosh grow box (doesn't draw anything on other platforms).  Create an FW_CGrowBox object in every root frame that can be resized.   If your frame is not the root frame, i.e. is embedded somewhere else, it is against HI conventions to leave the grow box.
  122.  
  123.      void MyFrame::CreateSubViews(Environment* ev)
  124.   {
  125.      ...
  126.         if (IsRoot(ev)) 
  127.         {
  128.                // ----- Create the GrowBox only in root frame
  129.                FW_CGrowBox* growBox = new FW_CGrowBox(ev, this, 0, contentRect.BotRight());
  130.         }
  131.      ...
  132.  
  133. When creating your views by resource you cannot use a runtime test for root frames.  The solution is to leave the grow box and add code in PostCreateViewFromStream to remove it afterward for non-root frames.
  134.  
  135.   FW_RGrowBox
  136.         (
  137.                 kGrowBoxID,                                             // view Id
  138.                 {H - FW_SBSIZE, V - FW_SBSIZE, H1, V1},        // bounds 
  139.                 FW_kGrowBoxBinding                                // standard grow box binding
  140.         )
  141.  
  142.   void MyFrame::PostCreateViewFromStream(Environment* ev)
  143.   {
  144.           // ----- Additional processing for non-root (i.e. embedded) frames
  145.           if (IsRoot(ev) == false) 
  146.           {
  147.                     // Remove the GrowBox (delete is enough to remove it from the subviews list)
  148.                     FW_CView* growBox = FindViewById(ev, kGrowBoxID);
  149.                     FW_ASSERT(growBox);
  150.                     delete growBox;
  151.        }
  152.        ...
  153.  
  154. Note:  in the current version the size and bindings attributes are actually hard-coded to avoid mistakes.
  155.  
  156.  
  157.  
  158. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  159. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.